/*
 * Copyright © 2024-2025 Wenze Wei
 *
 * This file is part of StadionOS.
 *
 * This Source Code Form is subject to the terms of the GNU General Public License, v. 2.0.
 * You can obtain a copy of the GPL at
 * https://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 */

#include "../include/string.h"

/**
 * @brief Find the length of the initial segment of a string that does not contain any of the characters in another string.
 *
 * @param str1 The string to search.
 * @param str2 The string containing the characters to search for.
 * @return The length of the initial segment.
 */
size_t Sstrcspn(const char *str1, const char *str2) {
    const char *p;  
    size_t count = 0;

    for (count = 0; str1[count]; count++) {  
        for (p = str2; *p; p++) {  
            if (str1[count] == *p)
                return count;
        }  
    }  
    return count;
}
